<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no"/>
    <title></title>
    <link rel="stylesheet" type="text/css" href="/tp/Public/css/bootstrap.min.css"/>
    <link rel="stylesheet" type="text/css" href="/tp/Public/css/font-awesome.min.css">
    <link rel="stylesheet" type="text/css" href="/tp/Public/css/style.css"/>
</head>

<body>
<div id="container">
    <!---->

    <include file="Public/tpl/header.html"/>

    <!---->

    <div id="main" class="container">
        <div class="row">
            <div class="col-md-8">
                <div class="panel panel-default">
                    <ol id="breadcrumb" class="panel-body breadcrumb">
                        <li>
                            <a href="{:U('article/index')}">首页</a>
                        </li>
                        <li>
                            <a href="{:U('Sort/detail',array('id'=>$article['sort_id']))}">{$article['sort_name']}</a>
                        </li>
                    </ol>
                    <div class="panel-heading">
                        <h2 class="form-group article-title">{$article['title']}</h2>
                        <h5>By <a href="{:U('User/info',array('id'=>$article['author_id']))}">{$article['article_author']}</a>
                            <span>{$article['create_time']}</span></h5>
                    </div>
                    <div class="panel-heading">
                        <div class="panel">
                            <p>
                                {$article['content']}
                            </p>
                        </div>
                        <a href="#reply">
                            <button type="submit" class="btn btn-primary" for="reply">评论</button>
                        </a>
                        <!---->
                        <if condition="($Think.session.uid eq $article['article_author'])or($visit_user_type eq admin)">

                            <button class="btn btn-primary" data-toggle="modal" data-target="#modal-article">编辑</button>
                            <!---->
                            <div class="modal fade" id="modal-article" tabindex="-1" role="dialog"
                                 aria-labelledby="myModalLabel" aria-hidden="true">
                                <div class="modal-dialog">
                                    <div class="modal-content">
                                        <div class="modal-header">
                                            <button type="button" class="close" data-dismiss="modal"
                                                    aria-hidden="true"></button>
                                            <h4 class="modal-title" id="myModalLabel">
                                                编辑
                                            </h4>
                                        </div>
                                        <form action="{:U('Article/edit')}" method="post">

                                            <div class="modal-body">
                                                <div class="panel-body">
                                                    <input type="hidden" name="id" value="{$article['id']}"/>
                                                    <textarea class="form-control" name="content" rows="5" cols="">{$article['content']}</textarea>
                                                </div>
                                            </div>
                                            <div class="modal-footer">
                                                <button type="button" class="btn btn-default" data-dismiss="modal">关闭
                                                </button>
                                                <button type="submit" class="btn btn-primary">提交更改</button>
                                            </div>
                                        </form>
                                    </div>
                                    <!-- /.modal-content -->
                                </div>
                                <!-- /.modal -->
                            </div>
                            <!---->
                            <!--<form style="display: inline" action="{:U('Article/delete')}" method="post">-->
                            <!--<input type="hidden" name="article_id" value="{$article['id']}"/>-->
                            <!--<button type="submit" class="btn btn-danger">删除</button>-->
                            <!--</form>-->

                            <button class="btn btn-danger" data-toggle="modal"
                                    data-target="#{$article['delete_id']}">删除
                            </button>
                            <!---->
                            <div class="modal fade" id="{$article['delete_id']}" tabindex="-1"
                                 role="dialog"
                                 aria-labelledby="$comment['from_id']}" aria-hidden="true">
                                <div class="modal-dialog modal-sm">
                                    <div class="modal-content">
                                        <div class="modal-header">
                                            <button type="button" class="close" data-dismiss="modal"
                                                    aria-hidden="true"></button>
                                            <h4 class="modal-title danger" id="myModalLabel">
                                                确认删除？
                                            </h4>
                                        </div>
                                        <form style="display: inline" action="{:U('Article/delete')}"
                                              method="post">
                                            <div class="modal-body">
                                                <input type="hidden"
                                                       name="article_id"
                                                       value="{$article['id']}"/>
                                                <center>
                                                    <button type="submit" class="btn btn-danger">删除
                                                    </button>
                                                    <button type="button" class="btn btn-default"
                                                            data-dismiss="modal">取消
                                                    </button>
                                                </center>
                                            </div>
                                        </form>
                                    </div>
                                    <!-- /.modal-content -->
                                </div>
                                <!-- /.modal -->
                            </div>
                            <if condition="$visit_user_type eq 'admin' and $article['is_top'] eq 0">
                                <button name="setTop" type="submit" class="btn btn-success">置顶</button>
                            </if>
                            <if condition="$visit_user_type eq 'admin' and $article['is_top'] eq 1">
                                <button name="unsetTop" type="submit" class="btn btn-warning">取消置顶</button>
                            </if>
                        </if>
                    </div>

                </div>
                <div class="panel panel-default">
                    <div class="panel-heading">
                        <h3 class="panel-title"><b>评论回复</b></h3>
                    </div>
                    <div class="panel-body">
                        <ul>
                            <if condition="$comments eq null">
                                <li class="list-group-item">
                                    暂无回复
                                </li>
                            </if>
                            <foreach name="comments" item="comment" key="key">

                                <li class="list-group-item">
                                    <a class="media-left" href="{:U('User/info',array('id'=>$comment['from_id']))}">
                                        <img src="__PUBLIC__/images/{$comment['avatar_name']}" alt="作者">
                                    </a>

                                    <div class="media-body">
                                        <p class="text-muted">
                                            <span><i class="icon-time icon"></i></span>
                                            <span>{$comment['create_time']}</span>
                                            <span><a href="{:U('User/info',array('id'=>$comment['from_id']))}">{$comment['from_name']}</a></span>
                                        </p>

                                        <h3 class="media-heading topic-list-heading">
                                            <span><i class="icon-envelope-alt icon"></i></span>

                                            <if condition="$comment['to_type'] neq user">
                                                <else/>
                                                <a href="{:U('User/info',array('id'=>$comment['to_id']))}">@{$comment['to_name']}</a>
                                            </if>
                                            <span>{$comment['content']}</span>
                                        </h3>

                                        <h3 class="media-heading topic-list-heading ">
                                            <button class="btn btn-primary" data-toggle="modal"
                                                    data-target="#{$comment['reply_id']}">回复
                                            </button>
                                            <!---->
                                            <div class="modal fade" id="{$comment['reply_id']}" tabindex="-1"
                                                 role="dialog"
                                                 aria-labelledby="$comment['from_id']}" aria-hidden="true">
                                                <div class="modal-dialog">
                                                    <div class="modal-content">
                                                        <div class="modal-header">
                                                            <button type="button" class="close" data-dismiss="modal"
                                                                    aria-hidden="true"></button>
                                                            <h4 class="modal-title" id="myModalLabel">
                                                                回复
                                                            </h4>
                                                        </div>
                                                        <form action="{:U('Comment/add')}" method="post">

                                                            <div class="modal-body">
                                                                <div class="panel-body">
                                                                    <input type="hidden" name="article_id"
                                                                           value="{$comment['article_id']}"/>
                                                                    <!-- name="from_id" 取决于session['uid']-->
                                                                    <input type="hidden" name="to_id"
                                                                           value="{$comment['from_id']}"/>
                                                                    <input type="hidden" name="to_type"
                                                                           value="user"/>
                                                                    <textarea class="form-control" name="content"
                                                                              rows="5" cols=""></textarea>
                                                                </div>
                                                            </div>
                                                            <div class="modal-footer">
                                                                <button type="button" class="btn btn-default"
                                                                        data-dismiss="modal">关闭
                                                                </button>
                                                                <button type="submit" class="btn btn-primary">确定
                                                                </button>
                                                            </div>
                                                        </form>
                                                    </div>
                                                    <!-- /.modal-content -->
                                                </div>
                                                <!-- /.modal -->
                                            </div>

                                            <if condition="($Think.session.uid eq $comment['from_name'])or($$visit_user_type eq 'admin')">
                                                <input id="to_id" type="hidden" name="to_id"
                                                       value="{$comment['from_id']}"/>
                                                <input id="to_name" type="hidden" name="to_name"
                                                       value="{$comment['from_name']}"/>
                                                <button class="btn btn-primary" data-toggle="modal"
                                                        data-target="#{$comment['id']}">编辑
                                                </button>
                                                <!---->
                                                <div class="modal fade" id="{$comment['id']}" tabindex="-1"
                                                     role="dialog"
                                                     aria-labelledby="$comment['from_id']}" aria-hidden="true">
                                                    <div class="modal-dialog">
                                                        <div class="modal-content">
                                                            <div class="modal-header">
                                                                <button type="button" class="close" data-dismiss="modal"
                                                                        aria-hidden="true"></button>
                                                                <h4 class="modal-title" id="myModalLabel">
                                                                    编辑
                                                                </h4>
                                                            </div>
                                                            <form action="{:U('Comment/edit')}" method="post">

                                                                <div class="modal-body">
                                                                    <div class="panel-body">
                                                                        <input type="hidden" name="comment_id"
                                                                               value="{$comment['id']}"/>
                                                                    <textarea class="form-control"
                                                                              name="comment_content" rows="5" cols="">{$comment['content']}</textarea>
                                                                    </div>
                                                                </div>
                                                                <div class="modal-footer">
                                                                    <button type="button" class="btn btn-default"
                                                                            data-dismiss="modal">关闭
                                                                    </button>
                                                                    <button type="submit" class="btn btn-primary">提交更改
                                                                    </button>
                                                                </div>
                                                            </form>
                                                        </div>
                                                        <!-- /.modal-content -->
                                                    </div>
                                                    <!-- /.modal -->
                                                </div>
                                                <!---->
                                                <button class="btn btn-danger" data-toggle="modal"
                                                        data-target="#{$comment['delete_id']}">删除
                                                </button>
                                                <!---->
                                                <div class="modal fade" id="{$comment['delete_id']}" tabindex="-1"
                                                     role="dialog"
                                                     aria-labelledby="$comment['from_id']}" aria-hidden="true">
                                                    <div class="modal-dialog modal-sm">
                                                        <div class="modal-content">
                                                            <div class="modal-header">
                                                                <button type="button" class="close" data-dismiss="modal"
                                                                        aria-hidden="true"></button>
                                                                <h4 class="modal-title danger" id="myModalLabel">
                                                                    确认删除？
                                                                </h4>
                                                            </div>
                                                            <form style="display: inline"
                                                                  action="{:U('Comment/delete')}"
                                                                  method="post">
                                                                <div class="modal-body">
                                                                    <input type="hidden" name="comment_id"
                                                                           value="{$comment['id']}"/>
                                                                    <center>
                                                                        <button type="submit" class="btn btn-danger">删除
                                                                        </button>
                                                                        <button type="button" class="btn btn-default"
                                                                                data-dismiss="modal">取消
                                                                        </button>
                                                                    </center>
                                                                </div>
                                                            </form>
                                                        </div>
                                                        <!-- /.modal-content -->
                                                    </div>
                                                    <!-- /.modal -->
                                                </div>
                                            </if>
                                        </h3>
                                    </div>

                                </li>
                            </foreach>
                        </ul>
                    </div>
                </div>
                <div class="panel panel-default">
                    <div class="panel-heading">
                        <form action="{:U('Comment/add')}" method="post">
                            <textarea id="reply" class="form-control" name="content" rows="5" cols=""></textarea>
                            <input type="hidden" name="to_id" value="{$sort['name']}"/>
                            <br/>
                            <input type="hidden" name="article_id"
                                   value="{$article ['id']}"/>
                            <input type="hidden" name="to_id"
                                   value="{$article['author_id']}"/>
                            <input type="hidden" name="to_type"
                                   value="article"/>
                            <button type="submit" class="btn btn-default">评论</button>
                        </form>
                    </div>
                </div>

            </div>


        </div>

        <div class="col-md-4">


        </div>
    </div>

</div>

<!---->
</div>
<!---->

<include file="Public/tpl/footer.html"/>
<!---->
<script src="/tp/Public/js/jquery-1.11.0.js" type="text/javascript" charset="utf-8"></script>
<script src="/tp/Public/js/bootstrap.min.js" type="text/javascript" charset="utf-8"></script>
<script src="/tp/Public/js/main.js" type="text/javascript" charset="utf-8"></script>
</body>

</html>